const btn = document.querySelector('.choice-more-btn')
var goback = document.querySelector('.goBack')
var sliderbar = document.querySelector('.return1')
document.addEventListener('scroll', function() {
    if (window.pageYOffset >= 1200) {
        goback.style.display = 'block'
    } else {
        goback.style.display = 'none'
    }
})
goback.addEventListener('click', function() {
    // window.scroll(0, 100)
    animate(window, 0)
})

function animate(obj, target, callback) {
    clearInterval(obj.timer)
    obj.timer = setInterval(function() {
        var step = (target - window.pageYOffset) / 10
        step = step > 0 ? Math.ceil(step) : Math.floor(step)
        if (window.pageYOffset == target) {
            clearInterval(obj.timer)
                // if (callback) {
                //     callback()
                // }
            callback && callback()
        }
        // obj.style.left = obj.offsetLeft + step + 'px'
        window.scroll(0, window.pageYOffset + step)
    }, 15)
}